import {ResDataType} from "./ajax";
import  axios from "./ajax"

//查询用户信息
export async function getUserInfoServe(): Promise<ResDataType> {
    const url = `/api/user/info`;
    const result = (await axios.get(url)) as ResDataType;
    return result;
}
//注册用户

export async function registerUserInfoServe(
    username: string,
    password: string,
    naLable?: string): Promise<ResDataType> {
    const url = `/api/user/register`;
    //封装程一个resp body的json数据进行请求
    const body = {username,password,naLable: naLable || username};
    const result = (await axios.post(url,body )) as ResDataType;
    // console.log(JSON.stringify(result))
    return result;
}
//登入用户
export async function loginUserInfoServe(
    username: string,
    password: string): Promise<ResDataType> {
    const url = `/api/user/login`;
    //封装程一个resp body的json数据进行请求
    const body = {username,password};
    const result = (await axios.post(url,body )) as ResDataType;
    // console.log(JSON.stringify(result))
    return result;
}